package test3_28.demo04;

import java.time.Duration;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

public class Homework16_2_Test {
    public static void main(String[] args) {

        //1.输出当前日期是星期几.
        Date date = new Date(System.currentTimeMillis());
        System.out.println(date);
        System.out.println("当前日期是星期" + date.getDay());

        //2.输出当前日期是当年的第多少天.
        Calendar calendar = Calendar.getInstance();
        System.out.println("当前日期是第" + calendar.get(Calendar.DAY_OF_YEAR) + "天");

        //3.接收一个生日【1998-7-9】，计算出此人的年龄
        LocalDate date1 = LocalDate.now();
        LocalDate birthday = LocalDate.of(1998, 7, 9);
        Duration duration = Duration.between(birthday.atStartOfDay(), date1.atStartOfDay());
        System.out.println("当前年龄：" + duration.toDays() / 365);

        //4.计算出90天后的日期，并输出
        System.out.println(date1.plusDays(90));

    }
}
